package com.example.campuslink.commen.db.userNumber

import androidx.room.TypeConverter
import com.example.campuslink.commen.db.invitation.InvitationTable
import com.example.campuslink.commen.db.userInfo.UserInfoTable
import com.example.campuslink.model.ChildrenCommendData
import com.example.campuslink.model.DeepSeekTalkData
import com.example.campuslink.model.SearchWordData
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken

class ChildrenDataConverter {
    private val gson = Gson()

    // 转换数据库String到Java/Kotlin对象
    @TypeConverter
    fun fromJson(json: String?): ChildrenCommendData? {
        return json?.takeIf { it.isNotBlank() }?.let {
            gson.fromJson(it, ChildrenCommendData::class.java)
        }
    }

    // 转换Java/Kotlin对象到数据库String
    @TypeConverter
    fun toJson(obj: ChildrenCommendData?): String? {
        return obj?.let { gson.toJson(it) }
    }
}
